﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Reflection;
using System.Diagnostics;
using System.IO;
using System.Threading;

namespace TestProject1
{
    /// <summary>
    /// Summary description for UnitTest2
    /// </summary>
    [TestClass]
    public class CheckOrders1
    {
        [AssemblyInitialize]
        public static void AssemblyInit(TestContext context)
        {
            var v = MethodBase.GetCurrentMethod();
            Utilty.WriteTest(string.Format("{0}.{1}", v.DeclaringType.FullName, v.Name));
        }

        [AssemblyCleanup]
        public static void AssemblyCleanup()
        {
            var v = MethodBase.GetCurrentMethod();
            Utilty.WriteTest(string.Format("{0}.{1}", v.DeclaringType.FullName, v.Name));
        }

        [ClassInitialize]
        public static void ClassInit(TestContext context)
        {
            var v = MethodBase.GetCurrentMethod();
            Utilty.WriteTest(string.Format("{0}.{1}", v.DeclaringType.FullName, v.Name));
        }

        [ClassCleanup]
        public static void ClassCleanup()
        {
            var v = MethodBase.GetCurrentMethod();
            Utilty.WriteTest(string.Format("{0}.{1}", v.DeclaringType.FullName, v.Name));
        }

        [TestInitialize]
        public void TestInit()
        {
            var v = MethodBase.GetCurrentMethod();
            Utilty.WriteTest(string.Format("{0}.{1}", v.DeclaringType.FullName, v.Name));
        }

        [TestCleanup]
        public  void TestCleanup()
        {
            var v = MethodBase.GetCurrentMethod();
            Utilty.WriteTest(string.Format("{0}.{1}", v.DeclaringType.FullName, v.Name));
        }


        static CheckOrders1()
        {
            var v = MethodBase.GetCurrentMethod();
            Utilty.WriteTest(string.Format("{0}.{1}", v.DeclaringType.FullName, v.Name));
        }

        public CheckOrders1()
        {
            var v = MethodBase.GetCurrentMethod();
            Utilty.WriteTest(string.Format("{0}.{1}", v.DeclaringType.FullName, v.Name));
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestMethod]
        public void TestMethod11()
        {
            var v = MethodBase.GetCurrentMethod();
            Utilty.WriteTest(string.Format("{0}.{1}", v.DeclaringType.FullName, v.Name));
        }

        [TestMethod]
        public void TestMethod12()
        {
            var v = MethodBase.GetCurrentMethod();
            Utilty.WriteTest(string.Format("{0}.{1}", v.DeclaringType.FullName, v.Name));
        }
    }
    
    
    [TestClass]
    public class CheckOrders2
    {

        [ClassInitialize]
        public static void ClassInit(TestContext context)
        {
            var v = MethodBase.GetCurrentMethod();
            Utilty.WriteTest(string.Format("{0}.{1}", v.DeclaringType.FullName, v.Name));
        }

        [ClassCleanup]
        public static void ClassCleanup()
        {
            var v = MethodBase.GetCurrentMethod();
            Utilty.WriteTest(string.Format("{0}.{1}", v.DeclaringType.FullName, v.Name));
        }

        [TestInitialize]
        public void TestInit()
        {
            var v = MethodBase.GetCurrentMethod();
            Utilty.WriteTest(string.Format("{0}.{1}", v.DeclaringType.FullName, v.Name));
        }

        [TestCleanup]
        public  void TestCleanup()
        {
            var v = MethodBase.GetCurrentMethod();
            Utilty.WriteTest(string.Format("{0}.{1}", v.DeclaringType.FullName, v.Name));
        }


        static CheckOrders2()
        {
            var v = MethodBase.GetCurrentMethod();
            Utilty.WriteTest(string.Format("{0}.{1}", v.DeclaringType.FullName, v.Name));
        }

        public CheckOrders2()
        {
            var v = MethodBase.GetCurrentMethod();
            Utilty.WriteTest(string.Format("{0}.{1}", v.DeclaringType.FullName, v.Name));
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

       

        [TestMethod]
        public void TestMethod21()
        {
            var v = MethodBase.GetCurrentMethod();
            Utilty.WriteTest(string.Format("{0}.{1}", v.DeclaringType.FullName, v.Name));
        }

        [TestMethod]
        public void TestMethod22()
        {
            var v = MethodBase.GetCurrentMethod();
            Utilty.WriteTest(string.Format("{0}.{1}", v.DeclaringType.FullName, v.Name));
        }
    }
    class Utilty
    {
        public static void WriteTest(string s)
        {
            string fileName = "test.txt";

            if (!File.Exists(fileName))
            {
                File.CreateText(fileName).Close();
            }
            using (var file = File.AppendText(fileName))
            {
                file.WriteLine(s);
            }
            
        }
    }
}
